package unamed.level;

import basis.game.level.Terrain;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;

public class Tile implements Terrain{
    
    public static double SIZE=10;
    
    private double x,y;
    private int light,color;
    private Tiles type;
    private boolean solid;
    private Rectangle2D.Double bounds;
    private BufferedImage img;
    private boolean show=true;
    
    public Tile(double x,double y,Tiles type){
        this.x=x;
        this.y=y;
        this.type=type;
        bounds=new Rectangle2D.Double(x,y,SIZE,SIZE);
    }

    @Override
    public void setX(double x) {
        this.x=x;
    }

    @Override
    public void setY(double y) {
        this.y=y;
    }

    @Override
    public void move(double x,double y) {
        this.x+=x;
        this.y+=y;
    }

    @Override
    public void update(long l) {
        
    }

    @Override
    public void render(Graphics2D g) {
        //g.drawImage(img,null,(int)x,(int)y);
        g.setColor(new Color(
                (color>>16&0xff)*(light>>16&0xff)/255,
                (color>>8&0xff)*(light>>8&0xff)/255,
                (color&0xff)*(light&0xff)/255));
        g.fill(bounds);
    }

    @Override
    public double getX() {
        return x;
    }

    @Override
    public double getY() {
        return y;
    }

    @Override
    public Shape getBounds() {
        return bounds;
    }

    @Override
    public void setLight(int i) {
        light=i;
    }

    @Override
    public int getLight() {
        return light;
    }

    @Override
    public boolean isSolid() {
        return solid;
    }

    @Override
    public double getCenterX() {
        return bounds.getCenterX();
    }

    @Override
    public double getCenterY() {
        return bounds.getCenterY();
    }

    @Override
    public double getSize() {
        return SIZE;
    }

    @Override
    public void show(boolean s) {
        show=s;
    }

    @Override
    public boolean isShown() {
        return show;
    }
    
}